﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

    public static class ControlHelper
    {
        public static T Find<T>(this RepeaterItem repeaterItem, string id) where T : System.Web.UI.Control
        {
            return (T)repeaterItem.FindControl(id);
        }

        public static void AddClass(this System.Web.UI.AttributeCollection attributes, string className)
        {
            attributes.Add("class", className);
        }

        public static void AddIndex(this System.Web.UI.AttributeCollection attributes, int index)
        {
            attributes.Add("index", index.ToString());
        }

        public static void AddClassAndIndex(this System.Web.UI.AttributeCollection attributes, string className, int index)
        {
            attributes.AddIndex(index);
            attributes.AddClass(string.Format(className, index));
        }
    }